#_author_: chanceyang
#date:2020/10/28
import json
import re
from typing import *


def strToDics(str)->List[Dict]:
    pattern=re.compile(r"^(\d+\.)(.+)")
    strList=str.rstrip().split("\n")
    dicList=[]
    for i in strList:
        tmp = pattern.search(i.rstrip()).group(2)
        dicList.append(json.loads(tmp))
    return dicList

def strToList(str)->List[str]:
    strList=[]
    pattern = re.compile(r"(?<=\.)([/\w?=&]+)(?=\n)|(?<=\.)([/\w?=]+$)|(?<=\.)(\{[\s\S]+?\})(?!,)(?=\n)|(?<=\.)(\{[\s\S]+?\}$)|(?<=\.)(\[[\s\S]+?\])(?!,)(?=\n)|(?<=\.)(\[[\s\S]+?\]$)")
    L=pattern.findall(str)
    for T in L:
        for str in T:
            if len(str)>0:
                strList.append(str)
    return strList

if __name__=="__main__":
    str="""1.{"a":"\nabc","c":{"d":44}}\n2.{"b":2}\n3.{g:66}"""
    str1 = """1.{"a":1}"""
    str2="""1./courseapi/goodsUser/front/page?a=90&b=9\n2./courseapi/goodsUser/front/page1"""
    str3="""2.{"a":1}\n1./courseapi/goodsUser/front/page?a=90&b=9\n1.[{"a":"\nabc","c":{"d":44}},"4",{g:66}]\n3./courseapi/goodsUser/front/page1"""
    # pattern = re.compile(r"(\d+\.)([/\w?=]+)[\n]?|(?<=\d+\.)(\{[\s\S]+\})[\n]?|(\d+\.)(\[.+\])[\n]?")
    # pattern = re.compile(r"(?<=\.)([/\w?=&]+)(?=\n)|(?<=\.)([/\w?=]+$)|(?<=\.)(\{[\s\S]+?\})(?!,)(?=\n)|(?<=\.)(\{[\s\S]+?\}$)|(?<=\.)(\[[\s\S]+?\])(?!,)(?=\n)|(?<=\.)(\[[\s\S]+?\]$)")

    print(strToList(str))
